package cn.kgm.user.api.factory;

import cn.kgm.core.http.response.R;
import cn.kgm.user.api.UserTypeDealerFeignApi;
import cn.kgm.user.dto.dto.UserTypeDealerSaveDTO;
import cn.kgm.user.dto.dto.UserTypeDealerUpdateDTO;
import cn.kgm.user.dto.query.UserTypeDealerPageQuery;
import cn.kgm.user.dto.vo.UserTypeDealerVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * # 技术改变自己 #
 * toC客户
 * @author Kappi
 * @email yolo.jk@qq.com
 * @date  2024-04-13 16:44:52
 */
@Slf4j
@Component
public class UserTypeDealerFallbackFactory implements FallbackFactory<UserTypeDealerFeignApi> {

    @Override
    public UserTypeDealerFeignApi create(Throwable throwable) {
        throwable.printStackTrace();
        log.error("toC客户服务调用失败===>{}", throwable.getMessage());
        return new UserTypeDealerFeignApi() {

            @Override
            public R<IPage<UserTypeDealerVO>> page(UserTypeDealerPageQuery data) {
                return R.fail("toC客户,【page】方法调用失败===>" + throwable.getMessage());
            }

            @Override
            public R<UserTypeDealerVO> get(@PathVariable(value = "id" ) Long id) {
                return R.fail("toC客户,【get】方法调用失败===>" + throwable.getMessage());
            }

            @Override
            public R<Boolean> save(@RequestBody @Validated UserTypeDealerSaveDTO data) {
                return R.fail("toC客户,【save】方法调用失败===>" + throwable.getMessage());
            }

            @Override
            public R<Boolean> update(@RequestBody @Validated UserTypeDealerUpdateDTO data) {
                return R.fail("toC客户,【update】方法调用失败===>" + throwable.getMessage());
            }

            @Override
            public R<Boolean> delete(@PathVariable(value = "ids" ) Long[] ids) {
                return R.fail("toC客户,【delete】方法调用失败===>" + throwable.getMessage());
            }
        };
    }
}

